package com.dingreading.cloud.ssxcx.service.impl;

import com.dingreading.cloud.common.util.EnumType;
import com.dingreading.cloud.ssxcx.entity.Cmservices;
import com.dingreading.cloud.ssxcx.entity.table.CmservicesTableDef;
import com.dingreading.cloud.ssxcx.mapper.CmservicesMapper;
import com.dingreading.cloud.ssxcx.service.CmservicesService;
import com.mybatisflex.core.query.QueryCondition;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 学员服务表 服务层实现。
 *
 * @author EDY
 * @since 2025-07-29
 */
@Service
public class CmservicesServiceImpl extends BaseServiceImpl<CmservicesMapper, Cmservices, CmservicesTableDef> implements CmservicesService {

    @Override
    protected CmservicesTableDef getTable() {
        return CmservicesTableDef.cmservices;
    }

    @Override
    public List<Cmservices> getByStudentUid(String uid) {
        QueryCondition condition = QueryCondition.createEmpty()
                .and(table.memberUid.eq(uid))
                .and(table.status.eq(EnumType.ServiceStatus.OPEN_CARD.getStatus()));
        return getMapper().selectListByCondition(condition);
    }

    @Override
    public List<Cmservices> getByStudentUidAndSubjectUid(String studentUid, String subjectUid) {
        QueryCondition condition = QueryCondition.createEmpty()
                .and(table.memberUid.eq(studentUid))
                .and(table.subjectUid.eq(subjectUid))
                .and(table.status.eq(EnumType.ServiceStatus.OPEN_CARD.getStatus()));
        return getMapper().selectListByCondition(condition);
    }

}
